package com.shop.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.shop.dao.DeptDao;
import com.shop.entity.Dept;
import com.shop.service.DeptService;
@Service

public class DeptServiceImpl implements DeptService {
	@Resource
	private DeptDao deptDao;
	@Override
	@Transactional
	public Integer saveDept(Dept dept) {
		int result  =deptDao.saveDept(dept);
		deleteDept(20); //子表有数据，外键约束
		return result;
	}

	@Override
	@Transactional
	public Integer deleteDept(Integer id) {
		return deptDao.deleteDept(id);
	}

	@Override
	@Transactional(propagation=Propagation.SUPPORTS,readOnly=true)
	public Dept findById(Integer id) {
		return deptDao.findById(id);
	}

	@Override
	@Transactional(propagation=Propagation.SUPPORTS,readOnly=true)
	public List<Dept> findAll() {
		return deptDao.findAll();
	}

	public DeptDao getDeptDao() {
		return deptDao;
	}

	public void setDeptDao(DeptDao deptDao) {
		this.deptDao = deptDao;
	}

	
}
